package com.zzyl.controller.manager;

import com.zzyl.base.ResponseResult;
import com.zzyl.dto.BedDto;
import com.zzyl.service.BedService;
import com.zzyl.vo.BedVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(path = "bed")
@Api(tags = "床位管理")
public class BedController {

    @Autowired
    private BedService bedService;

    @ApiOperation("添加床位")
    @PostMapping(path = "/create")
    public ResponseResult<Void> addBed(@RequestBody BedDto bedDto){
        bedService.addBed(bedDto);
        return ResponseResult.success();
    }

    @ApiOperation("根据id获取床位信息")
    @GetMapping("/read/{id}")
    public ResponseResult<BedVo> readBed(@PathVariable("id") Long id) {
        BedVo bed = bedService.getBedById(id);
        return ResponseResult.success(bed);
    }

    @ApiOperation("修改床位信息")
    @PutMapping("/update")
    public ResponseResult<Void> updateBed(@RequestBody BedDto bedDto) {
        bedService.updateBed(bedDto);
        return ResponseResult.success();
    }

    @ApiOperation("根据id删除床位")
    @DeleteMapping("/delete/{id}")
    public ResponseResult<Void> deleteBed(@PathVariable("id") Long id) {
        bedService.deleteBedById(id);
        return ResponseResult.success();
    }
}
